//
//  AppDelegate.swift
//  swift_review
//
//  Created by Andrew on 2024/11/24.
//

import UIKit

@main
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow? //定义窗口属性

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        
        //创建一个UIWindow
        window = UIWindow.init(frame: UIScreen.main.bounds)
        //设置根视图控制器为自定义的viewcontroller
        let vc = YMTabBarController()
        let navi = YMNavigationController(rootViewController: vc)
        let rootViewController = navi
        window?.rootViewController = rootViewController
        //使window可见
        window?.makeKeyAndVisible()
        
        // 设置崩溃处理器
        //输出异常日志
        YMLogSwift.setup {[weak self] (stackTrace, completion) in
            print("Crash detected:")
            print(stackTrace)
            completion()
        }
        
//        CrashLogger.setupCrashHandlers()
//        setupSignalHandler()
        
        //输出异常日志
        NSSetUncaughtExceptionHandler { exception in
            print("++++++++++++++++++ RASH ++++++++++++++++++ \n\(exception)")
            print("++++++++++++++++++ Stack Trace ++++++++++++++++++ \n\(exception.callStackSymbols)")
        }
        
        setupCrashHandler()
        
        return true
    }
}

